// npm install pubsub-js --save 安装pubsubJs
import React, { Component } from 'react';
import PubSub from "pubsub-js"

class dsigzj extends Component {
  constructor(props) {
    super(props);
    this.state = { 
      content:''
    }
    this.input = React.createRef()
  }
  render() { 
    return ( 
      <div>
        <div>第四个组件content：{this.state.content}</div>
        <div>
          <input type="text" ref={this.input}></input>&nbsp;
          <button onClick={this.seveInput}>获取</button>
        </div>
      </div>
    );
  }
  seveInput = () => {
    this.setState({
      content:this.input.current.value
    })

    PubSub.publish("saveInput",this.input.current.value)
  }
}
 
export default dsigzj;